<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<html>
<head>
<title>已收信息列表</title>
<%@include file="/common/ec.jsp"%>
<%@include file="/common/extjs.jsp"%>
<%@include file="/common/meta.jsp"%>
</head>
<body>
<div class="x-panel-header">站内信息-收件箱</div>
<div class="x-toolbar">
  <form action="receiveIndex.do" method="post">
  <table width="99%">
    <tr>
      <td> 
		&nbsp;&nbsp;
		发送人：<s:textfield name="model.sender.name" size="8"/>
		&nbsp;&nbsp;
		<!--  
		标题：<s:textfield name="model.title" size="20"/>
		&nbsp;&nbsp;
		-->
		从：<input type="text" name="startDate" readonly="readonly" style="width: 100px" value='<s:date name="startDate" format="yyyy-MM-dd"/>' onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>&nbsp;
		至：<input type="text" name="endDate" readonly="readonly" style="width: 100px" value='<s:date name="endDate" format="yyyy-MM-dd"/>' onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>
		&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" value="查询" class="button">
	  </td>
	  <td align="right">
	  	<a href="newMsg.do"><img src="${ctx}/images/icons/sms.gif">&nbsp;新建信息</a>
	  	<a href="#" onclick="onRemove()">
	  	  <img src="${ctx}/images/icons/delete.gif">&nbsp;删除
	  	</a>
	  </td>
    </tr>
  </table>
  </form>
</div>
<ec:table items="items" var="item" retrieveRowsCallback="limit" sortRowsCallback="limit" 
	action="receiveIndex.do" 
	useAjax="false"
	doPreload="false" 
	pageSizeList="10,20,50" 
	editable="false"
	sortable="false" 
	rowsDisplayed="10" 
	generateScript="true"
	resizeColWidth="false" 
	classic="false" 
	width="100%" 
	height="320px"
	minHeight="320"
	toolbarContent="navigation|pagejump|pagesize|refresh|extend|status">
	<ec:row>
		<ec:column width="45" property="_select" title="选择" style="text-align:center;">
		  <input type="checkbox" name="selectedItems" value="${item.id}" style="border:0px;"/>
		</ec:column>
		<ec:column width="150" property="sender.name" title="发送人" style="border-right:0px;"/>
		<ec:column width="390" property="_content" title="内容" style="border-right:0px;" ellipsis="true">
			<s:if test="#attr.item.fileIds != null">
				<img src="${ctx}/images/icons/attachment.gif" title="有附件信息">
			</s:if>
			<s:else>
				<img src="${ctx}/images/icons/timeicon.gif" title="无附件信息">
			</s:else>
			<a href="#" onclick="view(${item.id})" title="查看">${item.content}</a>
		</ec:column>
		<ec:column width="140" property="createTime" title="发送时间" cell="date" format="yyyy-MM-dd HH:mm" style="border-right:0px; text-align:center;"/>
		<ec:column width="70" property="_isRead" title="状态" style="text-align:center;">
			<s:if test="#attr.item.isRead == 1"><div style="color:#339933;font-weight:bold;">已读</div></s:if>
			<s:else><div style="color:red;font-weight:bold;">未读</div></s:else>
		</ec:column>	
	</ec:row>
	<ec:column width="60" property="_0" title="操作" style="text-align:center;" sortable="false">
		  <a href="#" onclick="remove(${item.id})" title="删除">删除</a>
	</ec:column>
</ec:table>
<script type="text/javascript">
  function remove(id) {
    Ext.MessageBox.confirm('提示','确认要删除这条信息吗？删除后不能恢复！', function(btn){
        if (btn == 'yes') {
          window.location = "${ctx}/msg/receiveDel.do?model.id=" + id;
        }
    });
  }
  function onRemove(){
		 var sels = document.getElementsByName("selectedItems");
		    var checked = false;;
		    for(i = 0; i < sels.length; i++) {
		        if(sels[i].checked) {
		           checked = true;
		           break;
		        }
		    } 
		    if(!checked) {
		    	alert("请选择要删除的消息!");
		    	return;
		    }
		    if (confirm("确定要删除所选择的消息吗？删除后不能恢复!")){
		        	var from = document.getElementById("ec");
		    		from.action="receiveRemove.do";
		    		from.submit();
		    }
	}
</script>

<!-- 
<script type="text/javascript">
/**
 * 删除提交
 */
function remove(){
	 var sels = document.getElementsByName("selectedItems");
	    var checked = false;;
	    for(i = 0; i < sels.length; i++) {
	        if(sels[i].checked) {
	           checked = true;
	           break;
	        }
	    } 
	    if(!checked) {
	    	alert("请选择要删除的内容!");
	    	return;
	    }
	    if (confirm("确定要删除所选择的内容吗？删除后不能恢复!")){
	        	var from = document.getElementById("ec");
	    		from.action="remove.do";
	    		from.submit();
	    	
	    }
}
</script>
 -->
 <script type="text/javascript">
 function view(id){
		window.location.href="view.do?model.id=" + id + "&updateState=Y";
	}
 </script>
</body>
</html>